<?php
//print_r($_GET);

include('conex.php');
import_request_variables("gP","");

$sql = "select ";
$diaActual = date("d");
$mes = date("m");

for ($i=1;$i<=$diaActual;$i++){
	$sql .= "sum(if(day(fIngreso)= $i,1,0)),";
}
$sql .= "'x' FROM dat_registro where month(fIngreso) = $mes";

$sql .= " UNION ALL SELECT ";
for ($i=1;$i<=$diaActual;$i++){
	$sql .= "sum(if(day(fEgreso)= $i,1,0)),";
}
$sql .= "'x' FROM dat_registro where month(fEgreso) = $mes and nEvolucion = 4";
$texto = array("INGRESOS","DEFUNCIONES");
$resultado = mysql_query($sql,$link) or die(mysql_error());
$filas = mysql_fetch_row($resultado);

	$date[$x][0] = $texto[$x];
	for ($i=0;$i<$diaActual; $i++){
		$dia++;
		$data[$x][$i] = $dia;
		$data[$x][$i] = $filas[$i];		
		$total[$x] += $filas[$i];
	}
	$x++;

include('phplot-5/phplot.php');
$plot = new PHPlot(650, 350);

$which_btype = "full";				//Plot Border  // plotleft,plotright,both,full,none, 

$plot->SetDataType('text-data');
$plot->SetDataValues($data);

$plot->SetPlotType("bars");
$plot->SetDataColors(array('SlateBlue','red', 'green', 'blue','YellowGreen',
'aquamarine1','azure1','beige','brown','gold','gray','ivory',
'lavender','magenta','navy','orange','orchid','peru','pink','plum','purple','yellow'));

//	$plot->SetXLabelType("title");
	$plot->SetXLabel("Dias");
	$plot->SetYLabel("Casos");
//	$plot->SetTTFPath(getcwd());
//	$plot->SetDefaultTTFont("arial.ttf");	
//	$plot->SetTitle($denominacion);
    $plot->SetLegend(array("Ingresos: $total[0] ","Defunciones: $total[1] "));	
	$plot->SetXDataLabelAngle(90);	
 
// Coloca la escala del eje Y y el tipo de incremento
//$plot->SetPlotAreaWorld(NULL, 0,NULL,15);
$plot->SetYTickIncrement(1);
$plot->SetXTickIncrement(1);
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');

$plot->SetXLabelAngle(90);		

//$plot->SetXTickIncrement(1);
 
 //Other settings
	    $plot->SetBackgroundColor("#F3F3F3");		
		$plot->SetTextColor("blue");
		$plot->SetGridColor("black");
		$plot->SetLightGridColor(array(175,175,175));
		$plot->SetTickColor("black");
		$plot->SetTitleColor("navy"); // Can be array or name
	    $plot->SetPlotBorderType($which_btype);		


$plot->DrawGraph();


/*

# Turn off X tick labels and ticks because they don't apply here:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');

$plot->SetXLabelAngle(90);		

// Coloca la escala del eje Y y el tipo de incremento
$plot->SetPlotAreaWorld(NULL, 0,NULL,$max);
$plot->SetYTickIncrement(20);
//$plot->SetYTickIncrement(100);

# Turn on Y data labels:
$plot->SetYDataLabelPos('plotin');
$plot->SetYTickPos('plotleft');
$plot->SetYTickLabelPos('plotleft');
$plot->SetYTitle($tVer, 'plotleft');

# Format the Y Data Labels as numbers with 1 decimal place.
# Note that this automatically calls SetYLabelType('data').
$plot->SetPrecisionY(2); 
 //Other settings
	    $plot->SetBackgroundColor("#FFFFFF");		
		$plot->SetTextColor("blue");
		$plot->SetGridColor("black");
		$plot->SetLightGridColor(array(175,175,175));
		$plot->SetTickColor("black");
		$plot->SetTitleColor("navy"); // Can be array or name
	    $plot->SetPlotBorderType("full");		
		$plot->SetTextColor('black');
		
$plot->DrawGraph();

*/
?>